#ifndef __DICTIONARY_HPP__
#define __DICTIONARY_HPP__

#include <vector>
#include <string>
#include <utility>
#include <map>
#include <set>

using std::vector;
using std::string;
using std::pair;
using std::map;
using std::set;

class Dictionary
{
public:
    Dictionary(const Dictionary &) = delete;
    Dictionary & operator=(const Dictionary &) = delete;

    static Dictionary * createInstance();
    void init(const string & dictpath);//通过词典文件路径初始化词典
    vector<pair<string, int>> & getDict();//获取词典
    map<string, set<int>> & getIndexTable();//获取索引表
    string doQuery(string word);

private:
    Dictionary() {}
    ~Dictionary() {}

private:
    static Dictionary * pDict;

    vector<pair<string, int>> _dict;//有问题//词典
//通过词典文件路径初始化词典    map<string, set<int>> _indexTable;//索引表
    class AutoRelease
    {
    public:
        ~AutoRelease()
        {
            if(pDict)
            {
                delete pDict;
                pDict = nullptr;
            }
        }  
    };
    static AutoRelease release;
};


/*
Dictionary * Dictionary::pDict = nullptr;
Dictionary::AutoRelease Dictionary::release;
 */ 

#endif
